﻿CREATE TABLE [fb].[Account] (
    [AccountId]      INT            IDENTITY (1, 1) NOT NULL,
    [Number]         NVARCHAR (10)  NOT NULL,
    [Description]    NVARCHAR (MAX) NULL,
    [IsDefault]      BIT            NOT NULL,
    [Status]         INT            NOT NULL,
    [Version]        INT            NOT NULL,
    [CreatedDate]    DATETIME       NOT NULL,
    [UpdatedDate]    DATETIME       NOT NULL,
    [CounterpartyId] INT            NOT NULL,
    [CurrencyCode]   NVARCHAR (3)   NOT NULL,
    CONSTRAINT [PK_fb.Account] PRIMARY KEY CLUSTERED ([AccountId] ASC),
    CONSTRAINT [FK_fb.Account_fb.Counterparty_CounterpartyId] FOREIGN KEY ([CounterpartyId]) REFERENCES [fb].[Counterparty] ([CounterpartyId]),
    CONSTRAINT [FK_fb.Account_fb.Currency_CurrencyCode] FOREIGN KEY ([CurrencyCode]) REFERENCES [fb].[Currency] ([Code])
);






GO
CREATE NONCLUSTERED INDEX [IX_CounterpartyId]
    ON [fb].[Account]([CounterpartyId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_CurrencyCode]
    ON [fb].[Account]([CurrencyCode] ASC);

